<template>
  <div class="cartMain1">
      <!-- this is main1 -->
      <div v-for="item in carts">
          {{item.id}}  {{item.title}}
          <button @click="setCartsNumFn"> 购买</button>
      </div>
      </div>
</template>

<script>
import { mapActions, mapState, mapMutations} from "vuex";
export default {
  computed: {
    ...mapState({
      carts: (state) => state.carts.carts,
    }),
    
  },
  methods: {
    ...mapActions({
      //普通方法名：模块名/方法名
      setCartsFn: "carts/setCarts",
    }),
    ...mapMutations({
        setCartsNumFn:'carts/setCartsBuyNum'
    })
  },
  created() {
    this.setCartsFn();
  },
};
</script>

<style lang = 'scss'>
</style>